import { get, post, put, del } from "@/request";

export interface IInforNews {
  newsId?: number | string | null;
  newsTitle: string;
  newsContent: string;
  newsImg?: string;
  status?: number; // 0-无效,1-有效
  publishTime?: string;
  createTime?: string;
  updateTime?: string;
}

// 新增医疗新闻
export const createInforNews = (data: IInforNews) => {
  return post("/information/inforNews/addInforNews", data);
};

// 删除医疗新闻
export const deleteInforNews = (newsId: number | string) => {
  return del(`/information/inforNews/${newsId}`);
};

// 查询所有医疗新闻
export const fetchAllInforNews = () => {
  return get<{ data: IInforNews[] }>("/information/inforNews");
};

// 更新医疗新闻
export const updateInforNews = (data: IInforNews) => {
  return put("/information/inforNews/updateInforNews", data);
};

// 根据id查询医疗新闻详情
export const fetchInforNewsDetail = (newsId: number | string) => {
  return get<{ data: IInforNews }>(`/information/inforNews/${newsId}`);
}